wpmr_i=0;
wpmr_n=0;
function writedown(xml){
       
        var wp_string="";
        var wpmr_title,wpmr_pubDate,wpmr_comment_no,wpmr_creator; 
        
       window.x=xml.getElementsByTagName("item");
        for(;wpmr_i<x.length && wpmr_i<WpMobiReader_itemsperpage*wpmr_n;wpmr_i++){
            try{
            wpmr_title=x[wpmr_i].getElementsByTagName("title")[0].childNodes[0].nodeValue;
            wpmr_title=del_bracket(wpmr_title);            
            wpmr_pubDate=x[wpmr_i].getElementsByTagName("pubDate")[0].childNodes[0].nodeValue.substring(0,16);
            wpmr_creator=x[wpmr_i].getElementsByTagNameNS('*','creator')[0].childNodes[0].nodeValue;
            wpmr_comment_no=x[wpmr_i].getElementsByTagNameNS('http://purl.org/rss/1.0/modules/slash/','comments')[0].childNodes[0].nodeValue;
                        
            
            wp_string+='<div data-role="collapsible" ><h3>'+wpmr_title+'</h3><div><ul data-role="listview" data-mini="true"><li><a href="#wpmr_fullview" class="fullview_click" wpmr_viewnum="'+wpmr_i+'">阅读全文...</a></li><li>作者：'+wpmr_creator+'</li><li>'+wpmr_comment_no+'个评论</li><li>'+wpmr_pubDate+'</li></ul></div></div>';
            
            }catch(e){alert(e)}  
        }
    
        var ori_string='<div data-role="collapsible-set" data-iconpos="right" data-theme="b" >';
        $("#wpmr_itemlist").append(ori_string+wp_string+'</div>').trigger('create');
    
    }

 function del_bracket(str){ 
        var strback=str;
        if(str.indexOf(']')>0){
            var new_str=str.substring(str.indexOf(']')+1,str.length);  
            return new_str;
        }else{
            return strback
            }}


$(document).bind('pageinit',function(){    //All Start Here
    $("#wp_button").bind("click",function(){
         
 $.ajax({ 
url:WpMobiReader_rssurl, 
dataType: 'xml',
error: function(xml){ 
      alert('Error loading XML document'+xml); 
}, 
success: function(xml){
     wpmr_n++;
    writedown(xml);
} 
});
});

$(".fullview_click").live("click",function(){
var viewnum=$(this).attr("wpmr_viewnum");
var wpmr_subtitle=del_bracket(window.x[viewnum].getElementsByTagName("title")[0].childNodes[0].nodeValue);
var wpmr_full=window.x[viewnum].getElementsByTagNameNS('*','encoded')[0].childNodes[0].nodeValue;
wpmr_full='<h3>'+wpmr_subtitle+'</h3>'+wpmr_full;
var wpmr_gocomments=window.x[viewnum].getElementsByTagName('comments')[0].childNodes[0].nodeValue;

$("#wpmr_fullview > header > h1").text(wpmr_subtitle);
$("#wpmr_fullview > div[data-role='content']").html(wpmr_full);
$("#wpmr_fullview >footer >div>ul>li> a[rel='external']").attr("href",wpmr_gocomments);
})

})